﻿using Microsoft.Extensions.DependencyInjection;
using Serilog;
using AME.Setting;


namespace AME.Logger;

/// <summary>
/// Serilog inject into ASP.Net
/// </summary>
public static class Registererilog
{
    public static IServiceCollection UseSerilog(this IServiceCollection services)
    {
        services.AddSerilog((services, lc) => lc
            .ReadFrom.Configuration(SettingExtensions.Configuration)
            .ReadFrom.Services(services)
            .Enrich.FromLogContext());
            //.WriteTo.Console(new ExpressionTemplate(
            //    // Include trace and span ids when present.
            //    "[{@t:HH:mm:ss} {@l:u3}{#if @tr is not null} ({substring(@tr,0,4)}:{substring(@sp,0,4)}){#end}] {@m}\n{@x}",
            //    theme: TemplateTheme.Code)));

        return services;
    }
}